<?php
class User_model extends CI_Model{
	public function auth($userData){
		$query = $this->db->query("SELECT user_salt FROM users WHERE user_loginname='".$userData['username']."' AND user_role='admin'");
		if ($query->num_rows() > 0){
			$result = $query->row();
			$password = makeSalt($userData['password'], $result->user_salt);

			$queryPwd = $this->db->query("SELECT user_loginname, user_fullname, user_lastlogin FROM users WHERE user_loginname='".$userData['username']."' AND user_password='".$password."' AND user_role='admin'");
			if ($queryPwd->num_rows() > 0){
				return $queryPwd->row();
			}
		}
		return null;
	}
	
}